<?php

class Modules_Common_DB_RTUserProject extends BaseObject
{
	public static function GetTableName() {
        return 'rt_user_projects';
    }
    public static function &ById($id) {
        self::GetById($id);
    }
 	public static function &ByUser($id)
    {
    	$mcdt=new Modules_Common_DB_RTUserProject();
    	if(count(($ids=$mcdt->GetIds('WHERE id_user="'.Mysql::EscapeString($id).'"')))>0)
        	return $mcdt->GetByIds($ids);
        else
        	return array();
    }
	public static function &SearchByProject($id)
    {
    	$mcdt=new Modules_Common_DB_RTUserProject();
    	if(count(($ids=$mcdt->GetIds('WHERE id_projects="'.Mysql::EscapeString($id).'"')))>0)
        	return $mcdt->GetByIds($ids);
        else
        	return array();
    }
public static function &PermissionOnProject($userid, $projectid)
    {
    	$mcdt=new Modules_Common_DB_RTUserProject();
    	if(count(($ids=$mcdt->GetIds('WHERE id_projects="'.Mysql::EscapeString($projectid).'" and id_user="'.Mysql::EscapeString($userid).'"')))>0)
        	return true;
        else
        	return false;
    }
    
}